// pages/bookingregister/bookingregister.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hiddenName:false,
    hiddenName1:true,
    hiddenName2:true,
    inputValue:null,
    table:[],
  // doctor
  doctorList:[
    {
      image:"../image/personal.png",
      name: "张秀",
      section:"儿童专科",
      position:"主任医师",
      more:"更多医生",
      icon: '../image/jiantou.png'
    },
    {
      image: "../image/personal.png",
      name: "张秀",
      section: "儿童哮喘专科",
      position: "主任医师",
      more: "更多医生",
      icon: '../image/jiantou.png'
    },
  ],
  // more
  more:[{
    more_doctor:"更多医生",
    icon: '../image/jiantou.png'
  }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    wx.showModal({
      title: '温馨提示',
      showCancel:false,
      confirmText:'关闭',
			content: '【发热】(48小时内)患儿无需预约挂号,请到【请到急诊发热诊室就诊】。感谢您的支持配合,祝您及家人身体健康！',
			success: function(res) {
        console.log(res.confirm)
				if (res.confirm) {
				console.log('用户点击关闭')
				} 
			}
    })
    // 初始化科室列表
    wx.request({
      url:app.globalData.api+'depar/',
      method:'get',
      header: app.globalData.header,
      success: function(res) {
        that.setData({
          table:res.data
        })
      }
    })

  },
  handleInputChange(){
    this.setData({
      hiddenName:!this.data.hiddenName,
      hiddenName1:!this.data.hiddenName1,
      
   })
  },
  //监控输入框
  watchPassWord(event){
    let that = this
   wx.request({
     url: app.globalData.api+'search/',
     data: {
       keys:event.detail.value
     },
     method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
     // header: {}, // 设置请求的 header
     success: function(res){
       // success
      if(res.statusCode===200){
        let item = res.data
        that.setData({
          doctorList:item,
          hiddenName2:false
        })
      }
     },
   })
  },
  quxiao(){
    this.setData({
      hiddenName:false,
      hiddenName1:true,
      hiddenName2:true,
      'inputValue': ''
   })
  },
  //跳转科室预约
  onItemClick(e){
    var item1 = e.currentTarget.dataset.item
    var item = JSON.stringify(item1)
     wx.navigateTo({
       url: '../appointment/appointment?item=' + item ,
     })
  },
  //跳转医生主页
  doctor(e){
    let item = JSON.stringify(e.currentTarget.dataset.item)
    wx.setStorage({
      data: e.currentTarget.dataset.item.section,
      key: 'asd',
    })
    if(e.currentTarget.dataset.item.type==1){
      wx.navigateTo({
        url: '../doctor/doctor?item='+item,
      })
    }else if(e.currentTarget.dataset.item.type==0){
      wx.navigateTo({
        url: '../appointment/appointment?item='+item,
      })
    }
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})